<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit">
    <title>登录</title>
    <script src="/static/common/js/jquery_1.11.1.min.js"></script>
    <script src="/static/common/js/layer/layer.js"></script>

    <link rel="stylesheet" href="/static/admin/login/css/base.css">
    <link rel="stylesheet" href="/static/admin/login/css/style.css">
    <style id="style-1-cropbar-clipper">
        /* Copyright 2014 Evernote Corporation. All rights reserved. */
    .en-markup-crop-options {
        top: 18px !important;
        left: 50% !important;
        margin-left: -100px !important;
        width: 200px !important;
        border: 2px rgba(255,255,255,.38) solid !important;
        border-radius: 4px !important;
    }

    .en-markup-crop-options div div:first-of-type {
        margin-left: 0px !important;
    }
    </style></head>
<body>

<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <form id="login_form">
                <div class="panel loginbox">
                    <div class="text-center margin-big padding-big-top">
                        <h1>后台管理中心</h1>
                    </div>
                    <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="text" class="input input-big" name="name" id="username" placeholder="登录账号">
                                <span class="icon icon-user margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="password" class="input input-big" name="password" id="password" placeholder="登录密码">
                                <span class="icon icon-key margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="field">
                                <input type="text" class="input input-big" id="code" name="code" placeholder="填写右侧的验证码">
                                <img src="{:captcha_src()}" alt="" width="100" height="32" class="passcode" style="height:43px;cursor:pointer;" onclick="this.src='{:captcha_src()}'">
                            </div>
                        </div>
                    </div>
                    <div style="padding:30px;">
                        <input type="button" id="submitBtn" class="button button-block bg-main text-big input-big" value="登 录">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('#submitBtn').click(function(){
            var post_url = "{:url('/admin/login/do_login')}";
            $.post(post_url, $('#login_form').serialize(), function(data){
                if(data.code == 1){
                    layer.msg(data.msg,{icon:1});
                    setTimeout( redirect, 1000 );
                }else{
                    layer.msg(data.msg,{icon:2});
                }
            },'json');
        });

        function redirect()
        {
            location.href = "/admin/";
        }

        $("#code").focus(function()
        {
            $(document).on("keydown",function(event)
            {
                if( event.keyCode == 13 )
                {
                    $('#submitBtn').click();
                }
            });
            $("#code").unbind();
        });
    });
</script>
</body>
</html>